{extend name="public:base"}
{block name='css'}
<style>
    ::-webkit-scrollbar {display:none}
</style>
{/block}

{block name='body'}
<div class="view view-main white-navbar white-toolbar">
    <div data-name="home" class="page">

        <div class="navbar">
            <div class="navbar-inner">
                <div class="left"><a href="{$my_prev_url|default='/'}" class="external"><i class="iconfont icon-fanhui"></i></a></div>
                <div class="center"><span>订单评价</span></div>
                <div class="right"></div>
            </div>
        </div>

        <div class="page-content padding-bottom50">

            <form name="form" action="" id="form"  method="post" onsubmit='ajaxSubmit();return false;'>
                <input type="hidden" name="id" value="{$info.id}" />
                <input type="hidden" name="status" value="5" />
                <div class="socre-list">
                    {volist name='info.goods_list' id='goods'}
                    <div class="li">
                        <input type="hidden" name="goods_id[]" value="{$goods.goods_id}" />
                        <input type="hidden" name="order_goods_id[]" value="{$goods.id}" />
                        <div class="mt">
                            <img src="{$goods.img}" alt="" />
                            <div class="y">
                                <p class="p1">{$goods.title}</p>
                                <p class="p3">{$goods.spec}</p>
                                <p class="p2"><span>￥{$goods.price}</span>x {$goods.num|floatval=###}</p>
                            </div>
                        </div>
                        <div class="sc">
                            <span class="z">评分：</span>
                            <div class="star"></div>
                        </div>
                        <textarea name="content[]" placeholder="请输入评价内容..."></textarea>
                    </div>
                    {/volist}
                </div>

                <div class="block">
                    <p class="row segmented-round">
                        <button class="col button button-big button-fill " style="background:#66ba61;">提交</button>
                    </p>
                </div>
            </form>

        </div>


    </div>
</div>
{/block}

{block name="js"}
<script type="text/javascript" src="__PUBLIC__/js/jquery.raty.js"></script>
<script type="text/javascript">
    function CheckForm()
    {
        var on = true ;
        $(".socre-list textarea").each(function(i){
            if ( ! $.trim($('.socre-list textarea').eq(i).val()) ) {
                messageToast( '请输入第' + (i+1) + '个商品的评价内容');
                on = false;
                return false ;
            }
        });
        if ( ! on ) {
            return false;
        } else {
            return true;
        }
    }


    $('.star').raty({
        path : '__PUBLIC__/img' ,
        scoreName : 'socre[]' ,
        score: 5
    });
    function ajaxSubmit() {
        if (!CheckForm()) {
            return false;
        }

        $.post("{:url('state')}", $('#form').serialize(), function(data){
            messageToast(data.info);
            if (data.status == 'y') {
                setTimeout(function(){
                    self.location = "{:url('user/index')}";
                }, 1000);
            }
        }, 'json');
    }
</script>
{/block}